<?php
/**
 * IMMOPHP
 * */
require 'kernel/common.php';

$GLOBALS['smarty']->assign('titre_site', $setting['titre_site'] . ' - ' . $lang['Contact'] );
$GLOBALS['smarty']->display($fichier_theme_header, $fichier_theme_header); 

if(isset($_POST['send_email']))
{
    // Verification jeton
    if($_POST['token'] != $_SESSION['token']) redirect('index.php');
    require_once 'kernel/includes/wamailer/class.mailer.php';
    require_once 'kernel/class/Contact.class.php';
    $mailer = new Mailer(); // declaration class d envoie
    $Contact = new Contact($paramClass, $mailer);	
    $Contact->send();
}

if(isset($_GET['error']))
{
    $GLOBALS['smarty']->assign('error_msg', true);
    $GLOBALS['smarty']->assign('error_class', 'error_warning');
    $GLOBALS['smarty']->assign('error_image', 'comment_warning');
    $GLOBALS['smarty']->assign('error_message', $_GET['error']);
    $GLOBALS['smarty']->assign('url_site',$setting['url_site']);
}

require_once 'kernel/class/Contact.class.php';
$agence_get = retrieve('GET','agence');
$annonce_get = retrieve('GET','annonce');

$Immophp->get_agence_select($agence_get, array('0' => $lang['Toute']) );

if($annonce_get != '')
{
    // Recuperation info
    $ann = $GLOBALS['db']->query("SELECT ref, titre_court FROM immo_annonce WHERE id = '". $annonce_get ."'",'BOTH');
    $sujet = 'REF : ' . $ann['ref'] .'';
}

$GLOBALS['smarty']->assign('lang', $lang);
$GLOBALS['smarty']->assign('sujet', isset($sujet) ? $sujet : '' );
$GLOBALS['smarty']->assign('token', $_SESSION['token']);
$GLOBALS['smarty']->assign('annonce_id', $annonce_get);

$GLOBALS['smarty']->display(get_template_file('contact.tpl'));

require_once 'kernel/footer.php';
?>